//----------------------------------- ??(String) ?? ?? ??  -----------------------------------
function win_pop(path, win_name, wi, he, scroll) {
	window.open(path,win_name,'width='+wi+',height='+he+',resizable=no,scrollbars='+scroll+', status=no,toolbar=no');
}
function win_pop_cookie(path, win_name, wi, he, scroll, cookie_name) {
	if ( getCookie( cookie_name ) == "" ) {
		window.open(path,win_name,'width='+wi+',height='+he+',resizable=no,scrollbars='+scroll+', status=no,toolbar=no');
	}
}
function setCookie( name, value, expiredays )
{
  var endDate = new Date();
  endDate.setDate( endDate.getDate()+ expiredays );
  document.cookie = name + "=" + escape( value ) + "; path=/; expires=" + endDate.toGMTString() + ";"
}

// ??? ???
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
// ???
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);






/******************************
*  ?? :  ??? Valid ???? *
*  ??? : 2002-01-25              *
*  parameter : string, space  *
*******************************/

function CheckValid(String, space)
{

   var retvalue = false;

   for (var i=0; i<String.length; i++)
   {		//String? 0("" ?? null)?? ??? false
      if (space == true)
      {
         if (String.charAt(i) == ' ')
         {			//String? 0? ??? space? ???? true(valid)
            retvalue = true;
            break;
         }
      } else {
         if (String.charAt(i) != ' ')
         {			//string? 0? ??? space? ?? ??? ???? true(valid)
            retvalue = true;
            break;
         }
      }
   }

   return retvalue;
}

/******************************
*  ?? :  Empty ? ?? ??    *
*  ??? : 2002-01-25              *
*  parameter : field, error_msg  *
*******************************/

function isEmpty(field, error_msg)
{
	// error_msg? ""?? alert? focusing? ?? ???
	if(error_msg == "") {
		if(!CheckValid(field.value, false)) 	{
			return false;
		} else {
			return true;
		}
	} else {
		if(!CheckValid(field.value, false)) {
			alert(error_msg);
			field.focus() ;
			return false;
		} else {
			return true;
		}
	}
}

function isNotSet(field, error_msg)
{ 
	//for hidden field....
	if(field.value == "")
	{
		alert(error_msg);
		return true;
	} else
	{
		return false;
	}
}

function haveSpace(field, error_msg)
{
	if(CheckValid(field.value, true))
	{
		alert(error_msg);
		field.focus();
		field.select();
		return true;
	}
	return false;
}


/******************************
*  ?? :  NumberCheck           *
*  ??? : 2002-03-29(denial)              *
*  parameter : field, error_msg  *
*******************************/
function isNotNumber(field, error_msg)
{
	var val = field.value;

	if(isNaN(val) ) {
		if(error_msg.length > 0) {
			alert(error_msg);
			field.focus();
			field.select();
		}
		return true;
	} else {
		return false;
	}
}

/******************************
*  ?? :  NumberCheck And Empty Check
*  ??? : 2002-04-02(denial)
*  parameter : field, error_msg
*******************************/
function isNotNumberOrEmpty(field, error_msg)
{
	var val = field.value;

	if(val.length == 0 || isNaN(val) ) {
		if(error_msg.length > 0) {
			alert(error_msg);
			field.focus();
			field.select();
		}
		return true;
	} else {
		return false;
	}
}

function alertAndFocus(field, error_msg)
{
	alert(error_msg);
	field.focus();
	field.select();
}

/***************************************
*  ?? : String ???? ???~ Check  *
*  ??? : 2002-01-25                           *
*  parameter : Form                              *
****************************************/
function isNotAlphaNumeric(field,error_msg)
{

   for (var i=0; i < field.value.length; i++)
   {
      if ( ( (field.value.charAt(i) < "0") || (field.value.charAt(i) > "9") ) &&
           ( ( (field.value.charAt(i) < "A") || (field.value.charAt(i) > "Z") ) &&
             ( (field.value.charAt(i) < "a") || (field.value.charAt(i) > "z") ) ) )
	  {
         alert(error_msg);
		 field.focus();
		 field.select();
		 return true;
	   }
   }

   return false;
}

// ??(String) ?? ??
function strLength(field)
{

   var Length = 0;

   var Nav = navigator.appName;
   var Ver = navigator.appVersion;

   var IsExplorer = false;

   var ch;

   if ( (Nav == 'Microsoft Internet Explorer') && (Ver.charAt(0) >= 4) )
   {
      IsExplorer = true;
   }

   if(IsExplorer)
   {

      for(var i = 0 ; i < field.value.length; i++)
      {

         ch = field.value.charAt(i);

         if ((ch == "\n") || ((ch >= "?") && (ch <= "?")) ||
             ((ch >="?") && (ch <="?")))
		{
	    	Length += 2;
		} else
		{
	    	Length += 1;
       	}

	  }

   }else {
      Length = field.value.length ;
   }

   return Length;
}

/****************************************
*  ?? : ??? ????                          *
*  ??? : 2002-01-25                              *
*  parameter : field, min, max, error_msg  *
*****************************************/
function isOutOfRange(field, min, max, error_msg)
{
	if(strLength(field) < min || strLength(field) > max)
	{
		alert(error_msg);
		field.focus();
		field.select();
		return true;
	}
	return false;
}

function isNotExactLength(field, len, error_msg) {
	if(strLength(field) != len) {
		alert(error_msg);
		field.focus();
		field.select();
		return true;
	}
	return false;
}

function isOutOfNumericRange(field, min, max, error_msg) {
	if(field.value < min || field.value > max) {
		alert(error_msg);
		field.focus();
		field.select();
		return true;
	}
	return false;
}
//---------------//


//------------------------------------- SELECT, CHECK BOX ?? ?? -------------------------------
/****************************************
*  ?? :  Select Box ???? ??            *
*  ??? : 2002-01-25                              *
*  parameter : field, error_msg                  *
*****************************************/

function isNotSelected(field, error_msg) {
	if(field.selectedIndex == 0) {
		alert(error_msg);
		field.focus() ;
		return true;
	} else {
		return false;
	}
}

/******************************
*  ?? :  Radio Button Check    *
*  ??? : 2002-01-25              *
*  parameter : field, error_msg  *
*******************************/
function isNotCheckedRadio(field, error_msg) {
	if ( field == null ) {
		alert(error_msg);
		return true;
	}

	if ( field.length == null ) {
		if ( field.checked == true ) {
			return false;
		} else {
			alert(error_msg);
			return true;
		}
	}

	for(i = 0; i < field.length; i++) {
		if(field[i].checked == true) {
			return false;
		}
	}
	alert(error_msg);
	return true;
}
//---------------//

/**
 * Radio Button? ??????
 */
function uncheckRadio(field) {
	for(i = 0; i < field.length; i++) {
		field[i].checked = false;
	}
}

/**
 * Radio Button? ??? ?? ????
 */
function getRadioVal(field) {
	for(i = 0; i < field.length; i++) {
		if(field[i].checked == true)
			return field[i].value;
	}
	return "";
}

//------------------------------------- ?? ?? ?? ?? ---
function checkDupID(id)
{
	if(isEmpty(id, "ID? ??? ???!")) return true;
	if(isNotAlphaNumeric(id,"ID? 4~10? ??? ?? ? ?? ?????? ??? ???!")) return true;
	//if(isOutOfRange(id,4, 10, "ID? ?? 2?~5?, ?? 4~10? ??? ??? ???!")) return true;
}

function checkName(name)
{
	if(isEmpty(name, "????? ??? ???!")) return true;
}

/*******************************
*  ?? : ???? Check            *
*  ??? : 2002-01-25                *
*  parameter : Form                  *
*******************************/
function isNotValidPassword(form) {

	if(isEmpty(form.password,"????? ??? ???!")) return true;
	if(isEmpty(form.password2,"????? ???? ???!")) return true;
	if(isNotAlphaNumeric(form.password,"????? 4~10? ??? ?? ? ?? ?????? ??? ???!")) return true;
	if(isNotAlphaNumeric(form.password2,"????? 4~10? ??? ?? ? ?? ?????? ??? ???!")) return true;
	if(isOutOfRange(form.password, 4, 10, "????? 4~10? ??? ?? ? ?? ?????? ??? ???!")) return true;
	if(isOutOfRange(form.password2, 4, 10, "????? 4~10? ??? ?? ? ?? ?????? ??? ???!")) return true;
	if(form.password.value != form.password2.value) {
		alert("????? ?? ???? ????.\n ?? ??? ???!");
		form.password.value="";
		form.password2.value="";
		form.password.focus();
		form.password.select();
		return true;
	}
	return false;
}

/******************************
*  ?? : ?????? Check     *
*  ??? : 2002-01-25               *
*  parameter : Form                  *
*******************************/
function isNotValidRegNo(form) {

	if(isEmpty(form.txtRegNo1,"??????? ??? ???!")) return true;
	if(isEmpty(form.txtRegNo2,"??????? ??? ???!")) return true;
	if(isNotNumber(form.txtRegNo1,"?????? ???? ???? ??? ???!")) return true;
	if(isNotNumber(form.txtRegNo2,"?????? ???? ???? ??? ???!")) return true;
	if(isNotExactLength(form.txtRegNo1, 6, "?????? ???? 6?????!")) return true;
	if(isNotExactLength(form.txtRegNo2, 7, "?????? ???? 7?????!")) return true;
	strchr = form.txtRegNo1.value.concat(form.txtRegNo2.value);
	if (strchr.length == 13	) {
		nlength = strchr.length;

		num1 = strchr.charAt(0);
		num2 = strchr.charAt(1);
		num3 = strchr.charAt(2);
		num4 = strchr.charAt(3);
		num5= strchr.charAt(4);
		num6 = strchr.charAt(5);
		num7 = strchr.charAt(6);
		num8 = strchr.charAt(7);
		num9 = strchr.charAt(8);
		num10 = strchr.charAt(9);
		num11 = strchr.charAt(10);
		num12 = strchr.charAt(11);

		var total = (num1*2)+(num2*3)+(num3*4)+(num4*5)+(num5*6)+(num6*7)+(num7*8)+(num8*9)+(num9*2)+(num10*3)+(num11*4)+(num12*5);
		total = (11-(total%11)) % 10;
	//	if (total == 11) total = 1;
	//	if (total == 10) total = 0;

		if(total != strchr.charAt(12)) {
			alert("??????? ???? ????. \n?? ??? ???!");
			form.txtRegNo1.value="";
			form.txtRegNo2.value="";
			form.txtRegNo1.focus();
			return true;
		}
		return false;
	}	else
		alert("??????? ???? ????. \n?? ??? ???!");
		form.txtRegNo1.value="";
		form.txtRegNo2.value="";
		form.txtRegNo1.focus();
		return true;
}


/******************************
*  ?? : ??????? Check  *
*  ??? : 2002-01-25               *
*  parameter : Form                  *
*******************************/
function isNotValidBID(form) {

	if(isEmpty(form.bid1,"???????? ??? ???!")) return true;
	if(isEmpty(form.bid2,"???????? ??? ???!")) return true;
	if(isEmpty(form.bid3,"???????? ??? ???!")) return true;
	if(isNotNumber(form.bid1,"??????? ???? ???? ??? ???!")) return true;
	if(isNotNumber(form.bid2,"??????? ?????? ???? ??? ???!")) return true;
	if(isNotNumber(form.bid3,"??????? ???? ???? ??? ???!")) return true;
	if(isNotExactLength(form.bid1, 3, "??????? ???? 3?????!")) return true;
	if(isNotExactLength(form.bid2, 2, "??????? ???? 2?????!")) return true;
	if(isNotExactLength(form.bid3, 5, "??????? ???? 5?????!")) return true;
	strchr = form.bid1.value.concat(form.bid2.value.concat(form.bid3.value));

	num1 = strchr.charAt(0);
	num2 = strchr.charAt(1);
	num3 = strchr.charAt(2);
	num4 = strchr.charAt(3);
	num5= strchr.charAt(4);
	num6 = strchr.charAt(5);
	num7 = strchr.charAt(6);
	num8 = strchr.charAt(7);
	num9 = strchr.charAt(8);
	num10 = strchr.charAt(9);

	var total = (num1*1)+(num2*3)+(num3*7)+(num4*1)+(num5*3)+(num6*7)+(num7*1)+(num8*3)+(num9*5);
	total = total + ((num9 * 5) / 10);
	var tmp = total % 10;
	if(tmp == 0) {
		var num_chk = 0;
	} else {
		var num_chk = 10 - tmp;
	}

	if(num_chk != num10) {
		alert("???????? ???? ????. \n?? ??? ???!");
		form.bid1.value="";
		form.bid2.value="";
		form.bid3.value="";
		form.bid1.focus();
		return true;
	}
	return false;
}
/******************************
*  ?? :  E-Mail Check            *
*  ??? : 2002-01-25              *
*  parameter : field, error_msg  *
*******************************/
function isNotValidEmail(field)
{
   var checkflag = true;
   var retvalue;

   if(field.value == "") {
	   retvalue = true;
   } else {

	   if (window.RegExp) {
		  var tempstring = "a";
		  var exam = new RegExp(tempstring);
		  if (tempstring.match(exam)) {
			 var ret1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
			 var ret2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");
			 retvalue = (!ret1.test(field.value) && ret2.test(field.value));
		  } else {
			 checkflag = false;
		  }
	   } else {
		  checkflag = false;
	   }

	   if (!checkflag) {
		  retvalue = ( (field.value != "") && (field.value.indexOf("@")) > 0 && (field.value.index.Of(".") > 0) );
	   }

   }
   if(retvalue) { return false;
   } else {
		alert("??? ??? ???? ????. \n?? ??? ???!");
		field.focus();
		field.select();
		return true;
   }
}

/******************************
*  ?? :  TelNumber Check      *
*  ??? : 2002-01-25              *
*  parameter : field, error_msg  *
*******************************/
function isNotValidTel(field) {

   var Count;
   var PermitChar =
         "0123456789-";

   for (var i = 0; i < field.value.length; i++) {
      Count = 0;
      for (var j = 0; j < PermitChar.length; j++) {
         if(field.value.charAt(i) == PermitChar.charAt(j)) {
            Count++;
            break;
         }
      }

      if (Count == 0) {
         alert("????? ???? ????. \n?? ??? ???!")
		 field.focus();
		 field.select();
		 return true;
         break;
      }
   }
   return false;
}
//---------------//


function isNotValidChar(field,error_msg) {

   var Count;
   var PermitChar = "0123456789-";  // ????? ???? ?? ????.

   for (var i = 0; i < field.value.length; i++) {
      Count = 0;
      for (var j = 0; j < PermitChar.length; j++) {
         if(field.value.charAt(i) == PermitChar.charAt(j)) {
            Count++;
            break;
         }
      }

      if (Count == 0) {
         alert(error_msg);
		 field.focus();
		 field.select();
		 return true;
         break;
      }
   }
   return false;
}

function isNotValidChar2(field,error_msg) {

   var NotPermitChar = "\"";  //?????? ??? ???? ?? ????.
//   var NotPermitChar = "<>\"^&|'\\ ";  //?????? ??? ???? ?? ????.

   if(field.value == "") return false;
   for (var i = 0; i < field.value.length; i++) {
      for (var j = 0; j < NotPermitChar.length; j++) {
         if(field.value.charAt(i) == NotPermitChar.charAt(j)) {
            ans = confirm(error_msg);
			if(ans == true) {
				return false;
			} else {
				field.focus();
				field.select();
				return true;
			}
         }
      }
   }
   return false;
}

function auto_fill_birth(txtRegNo1) {

	var year = txtRegNo1.value.substr(0,2);
	var month = txtRegNo1.value.substr(2,2);
	var date = txtRegNo1.value.substr(4,2);
	document.forms[0].year.value = year;
	document.forms[0].month.value = month;
	document.forms[0].date.value = date;

}

function hide_in(field) {
	if(field.value == field.defaultValue) field.value = "";
}
function show_out(field) {
	if(field.value == "") field.value = field.defaultValue;
}

function checkNumber(objname)
{
	var intErr = 1;
	var strValue = objname.value;
	var retCode = 0;

	for(i = 0; i < strValue.length; i++)
	{
		var retCode = strValue.charCodeAt(i);
		var retChar = strValue.substr(i, 1).toUpperCase();

		retCode = parseInt(retCode);

		// "3.4"? ????.
		if(!((retChar >= "0" && retChar <= "9") || retChar == "."))
		{
			intErr = 0; // break;
		}
	}

	var periodCnt = 0;

	while(strValue.indexOf(".") != -1)
	{
		periodCnt++;

		strValue = strValue.substr(strValue.indexOf(".") + 1, strValue.length - (strValue.indexOf(".") + 1));
	}

	// "3..4"? ??? ???.
	if(periodCnt > 1)
		intErr = 0;

	if (intErr!=1)
	{
		return true;
	}
	else return false;
}

/*function CheckID_onSubmit(form)
{
	if (form.id.value.length < 4 || form.id.value.length > 10 ||
	      IsAlphaNumeric(form.id.value) == false)
	{
	    alert("???ID? ??? ??? ???? 4-10????? ??????. \n??, ????? ????! ");
	    form.id.focus();
	    return (false);
	}
	return (true);
}*/

/**
 * <PRE>
 * Scroll ? ?? ? ?? ???
 * </PRE>
 * @param   theURL : ?? ?? ?? ????
 * @param   winName : ?? ??
 * @param   winTitle : ?? title
 * @param	width : ?? ?? ??
 * @param	height : ?? ?? ??
 * @param   param : ???? ?? argument
 */
function openNoScrollWin(theURL, winName, winTitle, width, height, param)
{
	var win = window.open(theURL + "?popupTitle=" + winTitle + "&tableWidth=" + width + param, winName, "menubar=no, scrollbars=no, resizable=no, width=" + width + ", height=" + height);
}

/**
 * <PRE>
 * Scroll ? ?? ? ?? ???
 * </PRE>
 * @param   theURL : ?? ?? ?? ????
 * @param   winName : ?? ??
 * @param   winTitle : ?? title
 * @param	width : ?? ?? ??
 * @param	height : ?? ?? ??
 * @param   param : ???? ?? argument
 */
function openScrollWin(theURL, winName, winTitle, width, height, param)
{
	var win = window.open(theURL + "?popupTitle=" + winTitle + "&tableWidth=" + width + param, winName, "menubar=no, scrollbars=yes, resizable=no, width="+width+", height="+height) ;
}

/**
 * <PRE>
 * ??? ?? ? ? ???? ??
 * </PRE>
 * @param   theURL : ?? ?? ?? ????
 * @param   winName : ?? ??
 * @param   winTitle : ?? title
 * @param	width : ?? ?? ??
 * @param	features : ??? ??? ?? ??
 * @param   param : ???? ?? argument
 */
function openFlexWin(theURL,winName,winTitle, width, features, param)
{
	var win = window.open(theURL + "?popupTitle=" + winTitle + "&tableWidth=" + width + param,winName,features);
}



///////////////////// Calendar ///////////////////////////

/* ??? ????? ? */
function showDateCalendar(dateField)
{
	var wid = (screen.width)/2 - 560/2 ;
	var hei = (screen.height)/2 - 480/2;
	
	window.open("/common/calendar/PopCalendar.jsp?popupTitle=??&type=date&dateField=" + dateField, "Calendar", "width=560,height=480,status=no,resizable=no,top="+hei+",left="+wid+"");
}
/* ??? ????? ? -- ???
dateField = "gridName, row, col" */
function showDateCalendarGrid(dateField)
{
	var wid = (screen.width)/2 - 560/2 ;
	var hei = (screen.height)/2 - 480/2;
	window.open("/common/calendar/PopCalendar.jsp?type=date&subType=grid&dateField=" + dateField, "Calendar", "width=560,height=480,status=no,resizable=no,top="+hei+",left="+wid+"");
}
/* ??? ?? ??? ????? ? */
function showDateTimeCalendar(dateField, timeField)
{
	var wid = (screen.width)/2 - 560/2 ;
	var hei = (screen.height)/2 - 480/2;
	window.open("/common/calendar/PopCalendar.jsp?type=datetime&dateField=" + dateField + "&timeField=" + timeField, "Calendar", "width=560,height=480,status=no,resizable=no,top="+hei+",left="+wid+"");
}


/**
 * <PRE>
 * ?? ??? ?? ??? ?? ??
 * </PRE>
 * @param   objectName : ??? ???? ????.(?? input type)
 */
function editStop(objectName) {
	objectName.blur();
}

/**
 * ??? ???? ??(Money) ???? ???.( ??(,) ???? ??.. )
 * @param	amount	"1234567"
 * @return	currencyString "1,234,567"
 */
function formatCurrency(amount)
{
	amount = new String(amount);
	var amountLength = amount.length;
	var modulus = amountLength % 3;
	var currencyString = amount.substr(0,modulus);
	for(i=modulus; i<amountLength; i=i+3) {
		if(currencyString != "") 
			currencyString += ",";
		currencyString += amount.substr(i, 3);
	}
	return currencyString;
}

///////////////////// LotteMRO Specific Functions ///////////////////////////
/**
 * ??? ??? ???? ????(??? ??? ??? ?? ?? ??? ??)
 *
 * @param	arrDiscount	??? ??? ??
 * @param	qty	??
 * @param	defaultSellPrice	?? ??
 * @return	discountPrice	???
 */
function calcDiscountPrice(arrDiscount, qty, defaultSellPrice)
{
	var discountPrice = defaultSellPrice;
	var prevQty = 0;

	for( i=0; i<arrDiscount.length; i++ ) {
		if(qty >= prevQty && qty < arrDiscount[i][0]) {
			break;
		} else {
			discountPrice = arrDiscount[i][1];
			prevQty = arrDiscount[i][0];
		}
	}
	
	return discountPrice;
}
/**
 * ??? ???? ????(??? ??? ??? ?? ?? ??? ??)
 *
 * @param	arrDiscount	??? ??? ??
 * @param	qty	??
 * @param	defaultSellPrice	?? ??
 * @param	addedPrice	???? ?? ??? ??(??? ??)
 * @return	???
 */
function calcSellPrice(arrDiscount, qty, defaultSellPrice, addedPrice)
{
	return (calcDiscountPrice(arrDiscount, qty, defaultSellPrice) + addedPrice) * qty;
}
/**
 * ??? ??? ????
 *
 * @param	defaultPrimeCost	?? ??
 * @param	addedPrice	???? ?? ??? ??(??? ??)
 * @return	??
 */
function calcPrimeCost(defaultPrimeCost, addedPrice)
{
	return defaultPrimeCost + addedPrice;
}

/*
 * ??? ?? ??? ????.
 */
function isNotValidBIZ(form) {

	if(isEmpty(form.bizregno1,"???????? ??? ???!")) return true;
	if(isEmpty(form.bizregno2,"???????? ??? ???!")) return true;
	if(isEmpty(form.bizregno3,"???????? ??? ???!")) return true;
	if(isNotNumber(form.bizregno1,"??????? ???? ???? ??? ???!")) return true;
	if(isNotNumber(form.bizregno2,"??????? ?????? ???? ??? ???!")) return true;
	if(isNotNumber(form.bizregno3,"??????? ???? ???? ??? ???!")) return true;
	if(isNotExactLength(form.bizregno1, 3, "??????? ???? 3?????!")) return true;
	if(isNotExactLength(form.bizregno2, 2, "??????? ???? 2?????!")) return true;
	if(isNotExactLength(form.bizregno3, 5, "??????? ???? 5?????!")) return true;
	strchr = form.bizregno1.value.concat(form.bizregno2.value.concat(form.bizregno3.value));

	num1 = strchr.charAt(0);
	num2 = strchr.charAt(1);
	num3 = strchr.charAt(2);
	num4 = strchr.charAt(3);
	num5 = strchr.charAt(4);
	num6 = strchr.charAt(5);
	num7 = strchr.charAt(6);
	num8 = strchr.charAt(7);
	num9 = strchr.charAt(8);
	num10 = strchr.charAt(9);

	var total = (num1*1)+(num2*3)+(num3*7)+(num4*1)+(num5*3)+(num6*7)+(num7*1)+(num8*3)+(num9*5);
	total = total + ((num9 * 5) / 10);
	var tmp = total % 10;
	if(tmp == 0) {
		var num_chk = 0;
	} else {
		var num_chk = 10 - tmp;
	}

	if(num_chk != num10) {
		alert("???????? ???? ????. \n?? ??? ???!");
		form.bizregno1.value="";
		form.bizregno2.value="";
		form.bizregno3.value="";
		form.bizregno1.focus();
		return true;
	}
	return false;
}

/**
 * Confirm?? ??? "?"?? false? "???"?? true? ????
 * (JSP ??? : if(didNotConfirm("??? ?????????")) return;)
 */
function didNotConfirm(question) {
	return !confirm(question);
}

/**
 * ???? ???? FORM element? ??? ??.
 * 
 * @param	??? ?? FORM
 */
function doInit(frm)
{
	for (i = 0; i < frm.elements.length; i++)
	{
		frm.elements[i].value = "";
	}
}

/******************************
*  ?? :  Positive NumberCheck           *
*  ??? : 2002-04-10(withsun)              *
*  parameter : field, error_msg  *
*******************************/
function isNotPositiveNumber(field, error_msg)
{
   for (var i=0; i < field.value.length; i++)
   {
      if ( field.value.charAt(i) < "1" || field.value.charAt(i) > "9" )
	  {
         alert(error_msg);
		 field.focus();
		 field.select();
		 return true;
	   }
   }
}


/**
 * ENTER? ?? ???? ???? Function??
 *
 * @param	func	??? Function?
 */
function enterKeyDown(func)
{
	enter = event.keyCode;
	if(enter == 13)
	{
		eval(func);
	}

}

/**
 * ??? ?? ???? ???? Function??
 *
 * @param	func	??? Function?
 */
function keyDown(func)
{
	enter = event.keyCode;
	if(enter == 13)
	{
		eval(func);
	}

}


/**
 * ??? 8?? ???? ????(YYYY-MM-DD or YYYY/MM/DD)? ?????.
 *
 * @param	source		??? 8?? ?????
 * @param	format		????
 * @return	ret			??? ?? ???
 **/
function dateFormat(source, format)
{
	ret = "";
	delimiter = "";

	if (format.indexOf("-") != -1)
		delimiter = "-";
	else if (format.indexOf("/") != -1)
		delimiter = "/";
	else
	{
		alert("??? ????? ???????.");
		return;
	}

	if (source.length == 8)
	{
		ret = source.substring(0, 4) + delimiter + source.substring(4, 6) + delimiter + source.substring(6, 8);
	} else if (source.length == 10)
	{
		ret = source.substring(0, 4) + delimiter + source.substring(5, 7) + delimiter + source.substring(8, 10);
	} else
	{
		alert("??? ????? ???????.");
		return;
	}
	return ret;
}

/**
 * ????? ???? ??
 *
 * @param	astrValue	????(yyyymmdd, yyyy/mm/dd, yyyy-mm-dd)
 * @param	astrNotNull:	nn:not null, "": null ??
 * @return	true/false
 **/
function blnOkDate(astrValue, astrNotNull)
{
	var arrDate;
	
	if (astrValue=='')
	{
		if (astrNotNull == "nn")
			return false;
		else
			return true;
	}else{	
		if (astrValue.indexOf("-") != -1) 
			arrDate = astrValue.split("-");
		else if (astrValue.indexOf("/") != -1) 
			arrDate = astrValue.split("/");
		else
		{
			if (astrValue.length != 8) return false;
			astrValue = astrValue.substring(0,4)+"/"+astrValue.substring(4,6)+"/" +astrValue.substring(6,8);
			arrDate = astrValue.split("/");
		}
	
		if (arrDate.length != 3) return false;		
		
		var chkDate = new Date(arrDate[0] + "/" + arrDate[1] + "/" + arrDate[2]);		
		if (isNaN(chkDate) == true ||
			(arrDate[1] != chkDate.getMonth() + 1 || arrDate[2] != chkDate.getDate())) 
		{
			return false;
		}
	}
	return true;
}


/**
 * ??? ?? ??? ??? ????? ???? ??(yyyymmdd or yyyy-mm-dd or yyyy/mm/dd)? ??? Calendar Popup
 *
 * @param	fgName	??????
 * @param	row		??
 * @param	col		??
 **/
function openCalendarInGrid(fgName, row, col)
{
	var fg = document.all(fgName);
	if (!blnOkDate(fg.TextMatrix(row, col), "nn"))
	{
		fg.TextMatrix(row, col) = "";
		showDateCalendarGrid(fgName + ", " + row + ", " + col);
	}
	else
		fg.TextMatrix(row, col) = dateFormat(fg.TextMatrix(row, col), "YYYY-MM-DD");

}

/**
 * INPUT field?? ??? ????? ???? ??(yyyymmdd or yyyy-mm-dd or yyyy/mm/dd)? ??? Calendar Popup
 *
 * @param	field	INPUT ??
 **/
function openCalendar(dateField)
{
	var obj = eval("document." + dateField);
	if (!blnOkDate(obj.value, "nn"))
	{
		obj.value = "";
		showDateCalendar(dateField);
	}
	else
		obj.value = dateFormat(obj.value, "YYYY-MM-DD");

}

/**
 * ????? ?? ', "? \', \" ?????.
 *
 * @param	str	??? ???
 **/
function toValidStr(str)
{
	/*
	alert(str);
	var ret = "";
	for (i = 0; i < str.length; i++)
	{
		if (str.charAt(i) == '\'')
			ret += '\\\'';
		else if (str.charAt(i) == '"')
			ret += '\\\"';
		else
			ret += str.charAt(i);
	}
	*/

	re1 = /\'/gi;
	re2 = /\"/gi;
	str = str.replace(re1, "\\\'");
	str = str.replace(re2, "\\\""); 
	return str;	
	
}

function encChar(str)
{
	var temp1 = "@@@@@";
	re1 = /\'/g;
	re2 = /\"/g;
	str = str.replace(re1, temp1);
	return str;
}	

function decChar(str)
{
	re3 = /@@@@@/g;
	str = str.replace(re3, "'");
	return str;
}


// system? ????? return: yyyymmdd
function strGetToDay()
{
 	 var today=new Date();
 	 
 	 var strToDay = today.getYear();
 	 
 	 if (today.getMonth()+1 < 10)
 	 	strToDay += "-0"+(today.getMonth()+1);
 	 else
 	 	strToDay += "-" + today.getMonth()+1;
 	 
 	 if (today.getDate() < 10)
 	 	strToDay += "-0"+today.getDate();
 	 else
 	 	strToDay += "-" + today.getDate();
 	 	
 	 return strToDay; 	 	 
}

//??? ?(val)? ????? num????? ?????? ????.
function round(val, num)
{
	val = val * Math.pow(10, num - 1);
	val = Math.round(val);
	val = val / Math.pow(10, num - 1);
	return val;
}


function isVaildMail(email)
{
     var result = false;

     if( email.indexOf("@") != -1 )
     {
          result = true;

          if( email.indexOf(".") != -1 )
          {
               result = true;
          }
          else
          {
               result = false;
          }
     }
     return result;
}



function isLoginname(obj) {
    len = obj.value.length;
    ret = true;

    if (len < 4)
		return false;
    if(!((obj.value.charAt(0) >= "a" && obj.value.charAt(0) <= "z") ||
       (obj.value.charAt(0) >= "A" && obj.value.charAt(0) <= "Z")))
		ret = false;		
    for (i = 1; i < len; i++) {
		if((obj.value.charAt(i) >= "0" && obj.value.charAt(i) <="9") ||
		   (obj.value.charAt(i) >= "a" && obj.value.charAt(i) <= "z") ||
		   (obj.value.charAt(i) >= "A" && obj.value.charAt(i) <= "Z"))
		    ;
		else 
		    ret = false;
    }
    return ret;
		   
}


//?? ???? ??? ???? 10???  ??
function roundValue(field) {

  field.value = Math.round(eval(field.value)/10) * 10

}

/*
 * ??? ?? ??? ????.
 */
function isNotValidBIZNo(form) {
	
	if(isEmpty(form.site_serial1,"???????? ??? ???!")) return true;
	if(isEmpty(form.site_serial2,"???????? ??? ???!")) return true;
	if(isEmpty(form.site_serial3,"???????? ??? ???!")) return true;
	if(isNotNumber(form.site_serial1,"??????? ???? ???? ??? ???!")) return true;
	if(isNotNumber(form.site_serial2,"??????? ?????? ???? ??? ???!")) return true;
	if(isNotNumber(form.site_serial3,"??????? ???? ???? ??? ???!")) return true;
	if(isNotExactLength(form.site_serial1, 3, "??????? ???? 3?????!")) return true;
	if(isNotExactLength(form.site_serial2, 2, "??????? ???? 2?????!")) return true;
	if(isNotExactLength(form.site_serial3, 5, "??????? ???? 5?????!")) return true;
	strchr = form.site_serial1.value.concat(form.site_serial2.value.concat(form.site_serial3.value));

	num1 = strchr.charAt(0);
	num2 = strchr.charAt(1);
	num3 = strchr.charAt(2);
	num4 = strchr.charAt(3);
	num5 = strchr.charAt(4);
	num6 = strchr.charAt(5);
	num7 = strchr.charAt(6);
	num8 = strchr.charAt(7);
	num9 = strchr.charAt(8);
	num10 = strchr.charAt(9);

	var total = (num1*1)+(num2*3)+(num3*7)+(num4*1)+(num5*3)+(num6*7)+(num7*1)+(num8*3)+(num9*5);
	total = total + parseInt((num9 * 5) / 10);
	var tmp = total % 10;

	if(tmp == 0) {
		var num_chk = 0;
	} else {
		var num_chk = 10 - tmp;
	}

	if(num_chk != num10) {
		alert("???????? ???? ????. \n?? ??? ???!");
		form.site_serial1.value="";
		form.site_serial2.value="";
		form.site_serial3.value="";
		form.site_serial1.focus();
		return true;
	}
	return false;
}
